using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;
using SalesPages.DomainModel;

namespace SalesPages.EntityFrameworkRepository.Mapping
{
    public class SchoolTourMap : EntityTypeConfiguration<SchoolTour>
    {
        public SchoolTourMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Id, t.SiteVersion });

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.ImageName)
                .HasMaxLength(50);

            this.Property(t => t.SchoolName)
                .HasMaxLength(50);

            this.Property(t => t.ShowType)
                .HasMaxLength(5);

            this.Property(t => t.IsTurnedOn)
                .IsFixedLength()
                .HasMaxLength(1);

            this.Property(t => t.SiteVersion)
                .IsRequired()
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("SchoolTour");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.ImageName).HasColumnName("ImageName");
            this.Property(t => t.DescBlurb).HasColumnName("DescBlurb");
            this.Property(t => t.SchoolName).HasColumnName("SchoolName");
            this.Property(t => t.Priority).HasColumnName("Priority");
            this.Property(t => t.ShowType).HasColumnName("ShowType");
            this.Property(t => t.IsTurnedOn).HasColumnName("IsTurnedOn");
            this.Property(t => t.SiteVersion).HasColumnName("SiteVersion");
        }
    }
}
